﻿<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8" />
    <title>资料导出</title>
    <link href="../../../css/main.css" rel="stylesheet" type="text/css" />
    <link
      href="../../../bstable/css/bootstrap.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../bstable/css/bootstrap-table.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../css/bootstrap-select.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <link
      href="../../../css/bootstrap.min.css"
      rel="stylesheet"
      type="text/css"
    />
    <style>
      input[name='btSelectAll'] {
        position: relative;
        bottom: 7px;
      }

      input[name='btSelectAll']::after {
        content: '全选';
        color: #000;
        position: relative;
        left: 15px;
        bottom: 3px;
      }

      .bootstrap-table {
        padding: 20px;
      }
    </style>
  </head>

  <body>
    <div class="tabe_div">
      <div
        class="search-wrap p_line text_ient"
        style="margin-bottom: -10px; border-bottom: 0"
      >
        <a class="find_a">学习形式：</a>
        <div id="studyMode" style="display: inline-block; padding-left: 1%; width: 150px"></div>
        <a class="find_a">学历层次：</a>
        <div id="myeducation" style="display: inline-block; padding-left: 1%; width: 150px"></div>
        <a class="find_a">学校：</a>
        <div id="myschool" style="display: inline-block; padding-left: 1%; width: 150px"></div>
        <a class="find_a">专业：</a>
        <div id="mycourse" style="display: inline-block; padding-left: 1%; width: 150px"></div>
        <a class="find_a">批次：</a>
        <div id="mybatch" style="display: inline-block; padding-left: 1%; width: 150px"></div>
        <input type="button" value="查询" class="but_find" id="search" />
      </div>
      <p class="p_line text_ient" style="margin-bottom: -10px">
        <a class="find_a">学生姓名：</a>
        <input
          type="text"
          id="name"
          class="form_input text_ient"
          placeholder="输入学生姓名"
        />
        <a class="find_a">学生身份证号：</a>
        <input
          type="text"
          id="card"
          class="form_input text_ient"
          placeholder="输入身份证号"
          maxlength="18"
        />
        <!-- <a class="find_a">学生手机号：</a>
            <input type="text" id="phone" class="form_input text_ient" placeholder="输入身份证号" maxlength="11" /> -->
      </p>
      <table
        data-url="json/data_alae_list.json"
        id="table"
        class="table_style"
        style="margin: 20px auto"
      ></table>

      <div style="text-align: center; margin: 20px auto">
        <input type="button" value="导出资料" class="but_find" id="ziliao" />
        <input type="button" value="导出表格" class="but_find" id="biaoge" />
      </div>
    </div>
    <script src="../../../js/jquery.js"></script>
    <script src="../../../js/common.js"></script>
    <script src="../../../js/laydate-master/laydate.js"></script>
    <script src="../../../bstable/js/bootstrap.min.js"></script>
    <script src="../../../bstable/js/bootstrap-table.js"></script>
    <script src="../../../bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../../js/bootstrap-select.min.js"></script>

    <script type="text/javascript">
      localStorage.setItem('name', '教务管理/资料导出(学历提升)');
      // 学历层次education，学校 school，专业train，批次batch
      $(function () {
        $('#search').on('click', function () {
          $('#table').bootstrapTable('refresh');
        });

        let studyMode = initialSelect('#studyMode', [], queryXLBatch)
        let myeducation = initialSelect('#myeducation', [], querySchool)
        let myschool = initialSelect('#myschool', [], queryCourse)
        let mycourse = initialSelect('#mycourse', [])
        let mybatch = initialSelect('#mybatch', [])

        // $('.selectpicker').selectpicker('refresh');

        $('#table').bootstrapTable({
          method: 'get',
          striped: true,
          singleSelect: false,
          url: baseUrl + 'studentInfo/getStudentList',
          dataType: 'json',
          pagination: true, //分页
          sidePagination: 'server',
          pageSize: 10,
          pageNumber: 1,
          search: false, //显示搜索框
          contentType: 'application/x-www-form-urlencoded',
          ajaxOptions: {
            headers: {
              Authorization: JSON.parse(localStorage.getItem('userInfo')).token,
            },
          },
          checkbox: true,
          queryParams: function (params) {
            params.trainType = 'education';
            params.studyMode = studyMode.getValue().map((item) => item.name).toString();
            params.educationName = myeducation.getValue().map((item) => item.name).toString()
            params.schoolName = myschool.getValue().map((item) => item.name).toString()
            params.majorName = mycourse.getValue().map((item) => item.name).toString()
            params.batch = mybatch.getValue().map((item) => item.name).toString()
            params.name = $('#name').val().trim();
            params.idNo = $('#card').val().trim();
            // params.mobile = $('#phone').val().trim()
            params.userType = 'ziliao';
            params.offset = params.offset / params.limit;
            return params;
          },
          responseHandler: function (res) {
            var list = res.data.result.records;
            var maps = {
              education: '学历提升',
              occupation: '职业技能',
              title: '职称评审',
              train: '执业资格',
            };
            var commits = [
              '已保存',
              '已提交',
              '财务驳回',
              '教务驳回',
              '待财务审核',
              '待教务审核',
              '教务确认',
            ];
            list.forEach(function (item, i) {
              item.trainType = maps[item.trainType];
              item.commitFlag = commits[item.commitFlag];
              !item && (list[i] = {});
              item.feeFlag = item.feeFlag == 1 ? '已缴费' : '未缴费';
            });
            return {
              rows: list,
              total: res.data.total,
            };
          },
          columns: [
            {
              checkbox: true,
              width: 80,
            },
            {
              field: 'no',
              title: '序号',
              sortable: true,
              align: 'center',
              formatter: function (value, row, index) {
                var pageSize =
                  $('#table').bootstrapTable('getOptions').pageSize;
                var pageNumber =
                  $('#table').bootstrapTable('getOptions').pageNumber;
                return pageSize * (pageNumber - 1) + index + 1;
              },
            },
            {
              title: '学生姓名',
              field: 'name',
              align: 'center',
              valign: 'middle',
            },
            {
              title: '身份证号',
              field: 'idNo',
              align: 'center',
            },
            {
              title: '老师手机号',
              field: 'teacherMobile',
              align: 'center',
            },
            {
              title: '老师姓名',
              field: 'teacherName',
              align: 'center',
            },
            {
              title: '报考类型',
              field: 'trainType',
              align: 'center',
            },
            {
              title: '提交日期',
              field: 'term',
              align: 'center',
            },
            {
              title: '审核状态',
              field: 'commitStr',
              align: 'center',
            },
          ],
        });
        var perm = JSON.parse(localStorage.getItem('userInfo')).perm;
        if (perm === 2) {
          $('#ziliao').hide();
          $('#biaoge').hide();
        }
      $('#ziliao').on('click', function () {
        if (perm === 2) return;
        var rows = $('#table').bootstrapTable('getSelections');
        var studentId = [];
        if (!rows.length) {
          return alert('请至少选择一项');
        }
        console.log(rows);
        rows.forEach(function (item) {
          studentId.push(item.name + '_' + item.idNo);
        });
        window.open(
          baseUrl +
            'studentInfo/dataExport' +
            '?studentId=' +
            studentId.join(',')
        );
        return false;
      });

      function transformRequest(obj) {
        //console.log('obj',obj)
        var str = [];
        for (var p in obj) {
          str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
        }
        //console.log(str.join("&"))
        return str.join('&');
      }

      $('#biaoge').on('click', function () {
        if (perm === 2) return;
        var rows = $('#table').bootstrapTable('getSelections');
        var studentId = [];
        if (!rows.length) {
          return alert('请至少选择一项');
        }
        rows.forEach(function (item) {
          studentId.push(item.id);
        });
        
        window.open(
          baseUrl +
            'studentInfo/sheetExport' +
            '?studentIds=' +
            studentId.join(',') +
            '&exportType=academic'
        );
      });

      $.ajax({
        url: baseUrl + 'education/queryModeList',
        async: false,
        method: 'Post',
        headers: {
          Authorization: JSON.parse(localStorage.getItem('userInfo')).token,
        },
        success: function (data) {
          const list = data.map((item) => ({ value: item.id, name: item.mode }));
          studyMode.update({ data: list});
        },
      });

      $.ajax({
        url: baseUrl + 'education/queryEducationList',
        async: false,
        method: 'Post',
        headers: {
          Authorization: JSON.parse(localStorage.getItem('userInfo')).token,
        },
        success: function (data) {
          const list = data.map((item) => ({ value: item.id, name: item.educationName }));
          myeducation.update({ data: list});
        },
      });

      function querySchool(data) {
        $.ajax({
          url: baseUrl + 'education/querySchoolList',
          method: 'Post',
          data: 'educationId=' + data.arr.map((item) => item.value).toString(),
          headers: {
            Authorization: JSON.parse(localStorage.getItem('userInfo')).token,
          },
          success: function (data) {
            const list = data.map((item) => ({ value: item.id, name: item.schoolName }));
            myschool.update({ data: list })
          },
        });
      }

      function queryCourse(data) {
        $.ajax({
          url: baseUrl + 'education/queryCourseList',
          method: 'Post',
          data: 'schoolId=' + data.arr.map((item) => item.value).toString(),
          headers: {
            Authorization: JSON.parse(localStorage.getItem('userInfo')).token,
          },
          success: function (data) {
            const list = data.map((item) => ({ value: item.id, name: item.courseName }));
            mycourse.update({ data: list});
          },
        });
      }

      function queryXLBatch(data) {
        $.ajax({
          url: baseUrl + 'education/queryBatchList',
          method: 'Post',
          data: {
            pid: data.arr.map((item) => item.value).toString(),
            trainType: 'education',
          },
          success: function (data) {
            const list = data.map((item) => ({ value: item.id, name: item.batch }));
            mybatch.update({ data: list});
          },
        });
      }
    });
    </script>
  </body>
</html>
